package io;

import java.io.*;

public class BufferWriterDemo {

    public static void main(String[] args) throws IOException {

        char[] cs = "温健".toCharArray();
        Reader r = new CharArrayReader(cs);
        Writer writer = new FileWriter("test.txt");
        // 字符输入流-》处理流-》缓存了一个cs
        BufferedReader bufferedReader = new BufferedReader(r);
        // 字符输出流-》处理流
        BufferedWriter bufferedWriter = new BufferedWriter(writer);
        int len = 0;
        while ((len = bufferedReader.read()) != -1) {
            bufferedWriter.write(len);
            bufferedWriter.newLine(); // 换行
        }
        int i = bufferedReader.read();
        bufferedReader.close();
        bufferedWriter.close();
        writer.flush();
        writer.close();
        r.close();
    }


}
